package org.javahispano.javacup.tacticas_aceptadas.jcrosas.chuky.util.matriz;

/**
 * @author Joan Crosas
 *
 */
public class MatrizItem implements Comparable<MatrizItem> {
	private Object objectX;
	private Object objectY;
	private double valor;
	
	public MatrizItem( Object objectX, Object objectY, double valor ) {
		this.objectX = objectX;
		this.objectY = objectY;
		this.valor = valor;
	}
	
	
	public Object getObjectX() {
		return objectX;
	}
	
	public Object getObjectY() {
		return objectY;
	}
	
	public double getValor() {
		return valor;
	}
	
	public int compareTo( MatrizItem item ) {
		if( valor > item.getValor() ) {
			return 1;
		} else if( valor < item.getValor() ) {
			return -1;
		}
		return 0;
	}
	
	public boolean contains( Object obj ) {
		if( obj == objectX || obj == objectY ) {
			return true;
		}
		return false;
	}
	
	public Object getObject( Class clase ) {
		if( clase.isInstance( objectX ) ) {
			return objectX;
		}
		if( clase.isInstance( objectY ) ) {
			return objectY;
		}
		return null;
	}
	
}